package com.example.hangzhou.welbeing.mytestdemoapp.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.transition.ChangeTransform;
import android.transition.TransitionManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.hangzhou.welbeing.mytestdemoapp.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 杭州惟君医疗科技有限公司10
 * Created by 20433 on 2018/5/9
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class ChangeTransformFragment extends Fragment {
    @Bind(R.id.fragment_transition_note_change_transform_bt)
    Button fragmentTransitionNoteChangeTransformBt;
    @Bind(R.id.fragment_transition_note_change_transform_tv_content)
    TextView fragmentTransitionNoteChangeTransformTvContent;
    @Bind(R.id.fragment_transition_note_change_transform_r1)
    RelativeLayout fragmentTransitionNoteChangeTransformR1;
    @Bind(R.id.fragment_transition_note_change_transform_r2)
    RelativeLayout fragmentTransitionNoteChangeTransformR2;
    @Bind(R.id.fragment_transition_note_change_transform_ll)
    RelativeLayout fragmentTransitionNoteChangeTransformLl;
    private Context mcontext;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mcontext = context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(mcontext, R.layout.fragment_transition_note_change_transform, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick(R.id.fragment_transition_note_change_transform_bt)
    public void onViewClicked() {

        TransitionManager.beginDelayedTransition(fragmentTransitionNoteChangeTransformLl, new ChangeTransform());
        if (fragmentTransitionNoteChangeTransformR1.getChildCount() > 0) {
            fragmentTransitionNoteChangeTransformR1.removeAllViews();
            //showRedSquare(fragmentTransitionNoteChangeTransformR2);
        } else {
            fragmentTransitionNoteChangeTransformR2.removeAllViews();
           // showRedSquare(fragmentTransitionNoteChangeTransformR1);
            fragmentTransitionNoteChangeTransformR1.getChildAt(0).setRotation(45);
        }


    }

}
